package com.thunder.reader;

import com.thunder.reader.provider.Feed;
import com.thunder.reader.ui.FeedListActivity;
import com.thunder.reader.ui.GroupListActivity;

import android.app.Activity;
import android.content.ContentUris;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;

public class ThunderFoxActivity extends Activity {
    private static final String TAG = FeedSettings.GLOBAL_TAG;
    public static final String EXTRA_URL = "url";
    
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        startReading();
        finish();
    }

    private void startReading() {
        final SharedPreferences sp = getSharedPreferences(FeedSettings.getSharedPreferencesName(), Context.MODE_PRIVATE);
        final int groupId = sp.getInt("group_id", -1);
        if (groupId == -1) {
            startActivity(new Intent(getApplication(), GroupListActivity.class));
        } else {
            final Intent intent = new Intent(getApplication(), FeedListActivity.class);
            intent.setData(ContentUris.withAppendedId(Feed.Group.CONTENT_URI, groupId));
            startActivity(intent);
        }
    }
}